﻿//===================================================================
// 西交投.NET产品框架 2019 版权所有     
//===================================================================
using System;
using System.ComponentModel.DataAnnotations;
using XCI.Data.Entity;

namespace XCI.Sys.Model
{
    /// <summary>
    /// 系统日志
    /// </summary>
    [Table("系统日志")]
    public class SysLog
    {
        /// <summary>
        /// 日志主键
        /// </summary>
        [Primary]
        [Column("日志主键", false)]
        public string Id { get; set; }

        /// <summary>
        /// 应用标识
        /// </summary>
        [Column("应用标识")]
        [Required(ErrorMessage = "请输入应用标识")]
        [StringLength(100, ErrorMessage = "应用标识不能超过100个字符")]
        public string AppId { get; set; }

        /// <summary>
        /// 操作类型值(1:操作;2:登录;3:异常)
        /// </summary>
        [Column("操作类型值")]
        public bool? OperateType { get; set; }

        /// <summary>
        /// 操作类型(1:操作;2:登录;3:异常)
        /// </summary>
        [Column("操作类型")]
        public string OperateTypeText { get; set; }

        /// <summary>
        /// 模块
        /// </summary>
        [Column("模块")]
        [StringLength(100, ErrorMessage = "模块不能超过100个字符")]
        public string Module { get; set; }

        /// <summary>
        /// 方法
        /// </summary>
        [Column("方法")]
        [StringLength(200, ErrorMessage = "方法不能超过200个字符")]
        public string Method { get; set; }

        /// <summary>
        /// 参数
        /// </summary>
        [Column("参数")]
        [StringLength(1000, ErrorMessage = "参数不能超过1000个字符")]
        public string ParamData { get; set; }

        /// <summary>
        /// IP地址
        /// </summary>
        [Column("IP地址")]
        [StringLength(100, ErrorMessage = "IP地址不能超过100个字符")]
        public string Ip { get; set; }

        /// <summary>
        /// 浏览器
        /// </summary>
        [Column("浏览器")]
        [StringLength(100, ErrorMessage = "浏览器不能超过100个字符")]
        public string Browser { get; set; }

        /// <summary>
        /// 请求地址
        /// </summary>
        [Column("请求地址")]
        [StringLength(500, ErrorMessage = "请求地址不能超过500个字符")]
        public string Url { get; set; }

        /// <summary>
        /// 耗时值
        /// </summary>
        [Column("耗时值")]
        public int? CostTime { get; set; }

        /// <summary>
        /// 耗时
        /// </summary>
        [Column("耗时")]
        public string CostTimeText { get; set; }

        /// <summary>
        /// 执行结果(0:失败;1:成功)
        /// </summary>
        [Column("执行结果值")]
        public bool? Result { get; set; }

        /// <summary>
        /// 执行结果(0:失败;1:成功)
        /// </summary>
        [Column("执行结果")]
        public string ResultText
        {
            get
            {
                if (Result.HasValue && Result.Value)
                {
                    return "成功";
                }
                return "失败";
            }
        }

        /// <summary>
        /// 信息
        /// </summary>
        [Column("信息")]
        [StringLength(1000, ErrorMessage = "信息不能超过1000个字符")]
        public string Message { get; set; }

        /// <summary>
        /// 详细信息
        /// </summary>
        [Column("详细信息")]
        public string Details { get; set; }

        /// <summary>
        /// 操作人主键
        /// </summary>
        [Column("操作人主键", false)]
        public string OperateUserId { get; set; }

        /// <summary>
        /// 操作人姓名
        /// </summary>
        [Column("操作人姓名")]
        [StringLength(100, ErrorMessage = "操作人姓名不能超过100个字符")]
        public string OperateUserName { get; set; }

        /// <summary>
        /// 操作时间
        /// </summary>
        [Column("操作时间")]
        public DateTime? OperateDateTime { get; set; }

        /// <summary>
        /// 复制对象
        /// </summary>
        public SysLog Clone()
        {
            return (SysLog)MemberwiseClone();
        }
    }
}
